<template>
	<view>
		<view class="bx-list" style="margin-top: 2rpx; padding-bottom: 20rpx;">
			<view class="bx-list-title">
				<view class="left">
					<view style="color: red;">*</view>关闭维修的原因
				</view>
			</view>
			<view class="input-textrea">
				<u--textarea class="textrea" v-model="params.closeReason" placeholder="请输入关闭维修的原因"></u--textarea>
			</view>
		</view>
		<view class="bx-title" style="margin-top: 4rpx; padding-top: 60rpx;">
			<view class="left">
				相关照片<view style="color: #8c8c8c;">(可传视频或图片，最多9个)</view>
			</view>
		</view>
		<view class="bx-upload">
			<uploadVideo @getdata="getdata" @delete="deletePicture" :fileType="13" :file="file">
			
			</uploadVideo>
			
		</view>
		<view class="bx-list" style="margin-top: 2rpx;">
			<view class="bx-list-title" @click="togoPeopleSelect(2)">
				<view class="left">
					<view style="color: red;">*</view>验证人
				</view>
				<view class="right1">
					<view :class="[params.verifyUserName!=''?'select-bg':'']">
						{{params.verifyUserName!=''?params.verifyUserName:'选择人员'}}
					</view>
					<view class="iconfont icon-app-xiangyou"></view>
				</view>
			</view>
		</view>
		<view class="bx-bottom">
			<view class="btn" @click="togoConfirm">提交</view>
		</view>
	</view>
</template>

<script>
	import uploadVideo from '@/components/uploadVideo/index.vue'
	export default {
		components: {
			uploadVideo
		},
		data() {
			return {
				gzPictrueList: [], //故障照片集合
				params: {
					verifyUserId: '', //验证人id
					verifyUserName: '', //验证人姓名
					closeReason: '', //关闭原因
					closePictures: '', //相关照片，多个之间用" ,"隔开
					id: '', //维修id
				}
			}
		},
		onLoad(options) {
			console.log('options===>', options)
			if (options.repairId) {
				this.params.id = options.repairId;
			}
		},
		onShow() {
			console.log('验证人员选中返回后的数据', this.wxpeopleList)
			if (this.wxpeopleList && this.wxpeopleList.id) {
				this.params.verifyUserName = this.wxpeopleList.realName;
				this.params.verifyUserId = this.wxpeopleList.id;
			}
		},
		methods: {
			getdata(e) {
				this.gzPictrueList = e;
				if (this.gzPictrueList.length > 0) {
					this.params.closePictures = "";
					let arry = []
					this.gzPictrueList.map(item => {
						arry.push(item)
					})
					this.params.closePictures = arry.toString()
				}
			},
			deletePicture(e) {
				this.gzPictrueList = e;
				if (this.gzPictrueList.length > 0) {
					this.params.closePictures = "";
					let arry = []
					this.gzPictrueList.map(item => {
						arry.push(item)
					})
					this.params.closePictures = arry.toString();
				}
			},
			togoConfirm() {
				if (!this.params.closeReason) return uni.$u.toast('请输入关闭维修原因');
				// if (!this.params.closePictures) return uni.$u.toast('请上传故障照片');
				if (!this.params.verifyUserId) return uni.$u.toast('请选择验证人');
				uni.$u.http.post(`/device/mobile/deviceRepair/closeRepair`, this.params).then(res => {
					console.log('res===>11', res)
					if (res.code == 0) {
						uni.$u.toast('提交成功')
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/subPackagesB/weiwaiRepair/index'
							})
						}, 1000)
					}
				}).catch(err => {})
			},
			togoPeopleSelect(type) {
				uni.navigateTo({
					url: '/pages/subPackagesC/list/peoplelist?type=' + type
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: #ffffff;
	}

	.bx-list {
		background: #fff;

		.bx-list-title {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 30rpx 20rpx;

			.left {
				display: flex;
				font-size: 34rpx;
				font-weight: 400;
				letter-spacing: 0px;
				line-height: 0px;
				color: rgba(0, 0, 0, 1);
			}

			.right {
				display: flex;
				justify-content: space-around;
				width: 50%;

				.sm-add {
					display: flex;
					align-items: center;
					padding: 10rpx 20rpx;
					border-radius: 24rpx;
					color: #0F53AC;
					background-color: rgba(2, 173, 130, 0.3);
					font-size: 24rpx;
				}

				.sm-sd {
					display: flex;
					align-items: center;
					padding: 10rpx 20rpx;
					border-radius: 24rpx;
					color: #0F53AC;
					background-color: rgba(2, 173, 130, 0.3);
					font-size: 24rpx;
				}
			}

			.right1 {
				display: flex;
				align-items: center;

				font-size: 34rpx;
				color: #8c8c8c;
			}
		}

		.bx-info {
			display: flex;
			padding: 10rpx 20rpx 20rpx 20rpx;

			.left-icon {
				image {
					width: 96rpx;
					height: 96rpx;
				}
			}

			.right-txt {
				padding-left: 32rpx;

				.txt1 {
					color: #000000;
					font-size: 34rpx;
					font-weight: 400;
				}

				.txt2 {
					color: #8c8c8c;
					font-size: 28rpx;
					margin-top: 10rpx;
				}
			}

		}

		.input-textrea {
			margin: 20rpx 20rpx 0 20rpx;
			border-radius: 8rpx;
			background: #f2f2f2;

			.textrea {
				background: #f2f2f2;
			}
		}

	}

	.bx-title {
		background: #fff;
		padding: 20rpx;

		.left {
			display: flex;
			font-size: 34rpx;
			font-weight: 400;
			letter-spacing: 0px;
			line-height: 0px;
			color: rgba(0, 0, 0, 1);
			background: #fff;
		}
	}

	.bx-upload {
		padding: 20rpx 30rpx;
		background: #fff;
	}

	.bx-title2 {
		color: #8c8c8c;
		font-size: 24rpx;
		padding: 30rpx;
		background: #f2f2f2;
	}

	.bx-bottom {
		width: 100%;
		// background: #f2f2f2;
		display: flex;
		justify-content: center;
		align-items: center;
		padding: 60rpx 0;

		.btn {
			width: 90%;
			height: 92rpx;
			border-radius: 12rpx;
			background: #0F53AC;
			display: flex;
			justify-content: center;
			align-items: center;
			color: #fff;
			font-size: 34rpx;
			font-weight: 500;
			letter-spacing: 0px;
			line-height: 0px;
		}
	}
</style>
